/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package factoryTotal;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;

/**
 *
 * @author wida46984148
 */
public class NaveWida extends NaveBase {
    int puntuancion;
    int vides;  //vidas nabe se aprobexa como contador si eso
    int muertes;    //contador muertes
    int bombasDisponibles = 3;
    DisparoBomba bomb;
    boolean disponeBombas = true;

    public NaveWida(float vida, float vidaT,int vides, DisparoWida shoot, DisparoBomba bomb, Image nau, Image nauDestroy){
        super(vida, vidaT, shoot, nau, nauDestroy);
        this.vides = vides;
        this.bomb = bomb;
    }

    @Override
    public void render(GameContainer gc, Graphics g){
        g.drawRect(pX, pY, nave.getWidth(), nave.getHeight());
        if(!(super.isMort() && vides==1)){
            if(!(super.isMort())){
                g.drawImage(nave, pX, pY);
            }else{
                g.drawImage(explosion, pX, pY);
                vides--;
                super.destruido = false;
                vida = vidaTotal;
                pX=350;
                pY=800;
                g.drawImage(nave, pX, pY);
                muertes++;
            }
        }else {
            muertes++;
            super.destruido = true;
        }
//        renderVida(gc, g);
//        renderVides(gc, g);
    }

    public void renderVida(GameContainer gc, Graphics g) {
        if (vida > 0) {
            g.setColor(Color.red);
            g.fillRect(30, 10, (vida / vidaTotal) * 200, 15);
        }
        g.setColor(Color.white);
        g.drawRect(30, 10, 200, 15);
    }

    public void renderVides(GameContainer gc, Graphics g) {
        for (int i = 0; i < vides; i++) {
            g.setColor(Color.white);
            g.fillRect(500+i*25, 10, 20, 20);
        }
    }

    public void renderBombas(GameContainer gc, Graphics g){
         for (int i = 0; i < bombasDisponibles; i++) {
            g.setColor(Color.white);
            g.fillRect(600+i*25, 10, 20, 20);
        }
    }

    public Disparo getBalaWida() {
        return disparo.clonarDisparo();
    }

    public Disparo getBomb(){
        return bomb.clonarDisparo();
    }

    public int getPuntuancion() {
        return puntuancion;
    }

    public void setPuntuancion(int puntuancion) {
        this.puntuancion += puntuancion;
    }

    public boolean isDisponeBombas() {
        return disponeBombas;
    }

    public void setBombasDisponibles(int num) {
        this.bombasDisponibles = bombasDisponibles-num;
        if(bombasDisponibles == 0){
            disponeBombas = false;
        }
    }


}
